package servlet_pack;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.sun.xml.internal.ws.wsdl.writer.document.Service;

import entity.Users;
import service.IUserService;
import service.impl.UserServiceImpl;

/**
 * Servlet implementation class SuccessUpdate
 */
@WebServlet("/SuccessUpdate")
public class SuccessUpdate extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public SuccessUpdate() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		int id = Integer.parseInt(request.getParameter("id"));
		String User = request.getParameter("user");
		String PWd = request.getParameter("pwd");
		Users users = new Users(id,User,PWd);
		IUserService userService = new UserServiceImpl();
		Boolean f=userService.UpdateByID(id, users);
		if(f) {
			request.getRequestDispatcher("QueryByPage").forward(request, response);
		}else {
			response.getWriter().println("修改失败！");
		}
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
